package com.example.cofeed.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.TypedValue;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.Navigator;

import java.util.List;

public class PinZhongAdapter extends BaseQuickAdapter<Navigator, BaseViewHolder> {
    public PinZhongAdapter() {
        super(R.layout.adapter_pin_zhong);
    }

    @Override
    protected void convert(BaseViewHolder helper, Navigator item) {

        TextView textView = helper.itemView.findViewById(R.id.tv_name);

        textView.setText(item.title);
        if (item.isSelect){
            textView.setTextColor(mContext.getResources().getColor(R.color.colorWhite));
            textView.setBackground(mContext.getResources().getDrawable(R.drawable.bg_channel_selected));
        }else {
            textView.setTextColor(Color.parseColor("#FF888888"));
            textView.setBackground(mContext.getResources().getDrawable(R.drawable.bg_channela_normal));
        }
        switch (item.title.length()) {
            case 4:
                textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
                break;
            case 5:
                textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
                break;
            case 6:
                textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
                break;
            default:
                textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
                break;
        }



    }

    public void select(Navigator navigator){
        navigator.isSelect = !navigator.isSelect;
        notifyDataSetChanged();
    }
}
